var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');

var app = getApp();
Page({
  data: {
    couponList: [],
    status: 0,
  },
  onLoad: function (options) {
    let status = options.status;
    wx.setNavigationBarTitle({
      title: "我的优惠券"
    })
    if (typeof status != "undefined") {
      this.setData({
        status: options.status
      });
    }
    this.getCouponList();
  },
  getCouponList() {
    let that = this;
    let user_id = wx.getStorageSync('userId');
    let userdata = {user_id:user_id,status:that.data.status};
    util.request(api.CouponList,userdata).then(function (res) {
      if (res.errno == 0) {
        that.setData({
          couponList:res.data,
        })
      }
    });
  },
  onReady: function () {

  },
  onShow: function () {

  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭
  }
})